package com.heima.feigns;
import com.heima.config.HeimaFeignAutoConfiguration;
import com.heima.feigns.fallback.ArticleFeignFallback;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.vos.SearchArticleVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(
        value = "leadnews-article",
        fallbackFactory = ArticleFeignFallback.class,
        configuration = HeimaFeignAutoConfiguration.class
)
public interface ArticleFeign {

    @GetMapping("/api/v1/author/findByUserName/{name}")
    public int findByUserName(@PathVariable("name") String name);

    /**
     * 返回1 保存成功
     * @param apAuthor
     * @return
     */
    @PostMapping("/api/v1/author/save")
    public ResponseResult save(@RequestBody ApAuthor apAuthor);

    @GetMapping("/api/v1/author/findAuthorByName/{id}")
    public ResponseResult findAuthorByName(@PathVariable("id") String id);

    @GetMapping("/api/v1/article/{id}")
    public ResponseResult<ApArticle> findApArticById(@PathVariable String id);

    @GetMapping("/api/v1/article/findArticle/{id}")
    ResponseResult<SearchArticleVO> findArticle(@PathVariable("id") Long id);

}
